package com.yunji.product.service.impl;

import com.yunji.product.dao.IProductTypeDao;
import com.yunji.product.domain.ProductTypeDO;
import com.yunji.product.params.ProductTypeParam;
import com.yunji.product.service.IProductTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package com.yunji.product.service.impl
 * @FileName ProductTypeServiceImpl.java
 * @Copyright Copyright © 2024 云集互联. All Rights Reserved
 * @Company com
 * @Version 1.0
 * @Since JDK1.8.0_201
 * @CreateTime 2024-04-01 23:38:08
 * @Description 商品类型接口实现
 * @Modification History
 * Author					History Time			Version			Description
 * -------------------------------------------------------------------------------
 * HuaAo				2024-04-01 23:38:08		1.0				1.0
 */
@Service
public class ProductTypeServiceImpl implements IProductTypeService {

    @Resource
    private IProductTypeDao productTYpeDao;

    /**
     * 查询商品类型列表
     *
     * @return 商品类型
     */
    @Override
    public List<ProductTypeDO> search(ProductTypeParam param) {
        return productTYpeDao.search(param);
    }

    /**
     * @param id 商品类型ID
     * @Title select
     * @Desc 查询商品类型详情
     * @Date 2024-06-12 10:53:20.779
     * @Return ProductType 商品类型详情
     */
    @Override
    public ProductTypeDO select(Long id) {
        return productTYpeDao.getById(id);
    }

    /**
     * @param productType 商品类型信息
     * @Title create
     * @Desc 创建商品类型信息
     * @Date 2024-06-12 10:49:08.959
     * @Return boolean 创建结果
     */
    @Override
    public boolean create(ProductTypeDO productType) {
        return productTYpeDao.save(productType);
    }

    /**
     * @param productType 商品类型信息
     * @Title update
     * @Desc 更新商品类型信息
     * @Date 2024-06-12 10:49:36.909
     * @Return boolean 更新结果
     */
    @Override
    public boolean update(ProductTypeDO productType) {
        return productTYpeDao.updateById(productType);
    }

    /**
     * @param ids 商品类型ID数组
     * @Title delete
     * @Desc 删除商品类型信息
     * @Date 2024-06-12 10:35:23.372
     * @Return boolean 删除结果
     */
    @Override
    public boolean delete(Long... ids) {
        return productTYpeDao.removeByIds(Arrays.asList(ids));
    }

    @Override
    public ProductTypeDO getById(Integer productTypeId) {
        return productTYpeDao.getById(productTypeId);
    }
}
